class Solution {
public:
    bool CheckCol[9][10];
    bool CheckRow[9][10];
    bool CheckGrid[3][3][10];

    bool isValidSudoku(vector<vector<char>>& board) {
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                char c = board[i][j];
                if (c != '.')
                {
                    if (CheckCol[i][c - '0'] || CheckRow[j][c - '0'] || CheckGrid[i / 3][j / 3][c - '0'])
                        return false;

                    CheckCol[i][c - '0'] = CheckRow[j][c - '0'] = CheckGrid[i / 3][j / 3][c - '0'] = true;
                }
            }
        }

        return true;
    }
};